<?php


namespace App\Models;


use Illuminate\Database\Eloquent\SoftDeletes;

class ProductsBatchLossModel extends BaseModel
{
    use SoftDeletes;
    protected $primaryKey = 'loss_id';
    protected $table = 'products_batch_loss';

    protected $fillable = ['batch_id', 'loss_num', 'loss_type', 'remark'];

    const MAP_LOSS_TYPE = [1 => '加工损耗', 2 => '质变损耗', 3 => '其他'];

    public function getLossTypeAttribute($value)
    {
        return self::MAP_LOSS_TYPE[$value]??'';
    }

    public function productsBatch()
    {
        return $this->belongsTo(ProductsBatchModel::class, 'batch_id', 'batch_id');
    }
}
